﻿<?php if(($sf_user->hasCredential("responsable")) || ($sf_user->hasCredential("livreur")) || ($sf_user->hasCredential("magasinier"))){?>
<h1>Liste des entrepots</h1>

<div id="list">
	<table>
	  <thead>
	    <tr>
	      <th>Nom</th>
	      <th>Adresse</th>
	      <th>Utilisateur</th>
	    </tr>
	  </thead>
	  <tbody>
	    <?php foreach ($entrepots as $entrepot): 
	    	if($key % 2 == 0) {
	    		$style = "background-color: #A9CADD";
	    	} else {
	    		$style = "background-color: #E6F7FE";
	    	}	    
	    ?>
	    <tr>
	      <td><a href="<?php echo url_for('entrepot/show?id='.$entrepot->getId()) ?>"><?php echo $entrepot->getNom() ?></a></td>
	      <td><?php echo $entrepot->getAdresse() ?></td>
	      <td><?php echo $entrepot->getUtilisateur() ?></td>
	    </tr>
	    <?php endforeach; ?>
	  </tbody>
	</table>
</div>
  <?php
	$this->entrepot = Doctrine_Query::create()->select('e.id')->from('Entrepot e')->leftJoin("Utilisateur u")
	->where("e.utilisateur_id = '".$sf_user->getAttribute("iduser")."'")->execute();

		if(($this->entrepot->count() == 0) && $sf_user->hasCredential('responsable')){
			echo '<br />';
			echo '<a href="';
			echo url_for('entrepot/new');
			echo '">Nouvel entrepôt</a>';
		};?>
<?php	}else{
	echo "Droits insuffisants.";
} ?>